package org.mch.func.m_px.yunsf;

import java.awt.Color;
import java.awt.Font;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;

import org.mch.biz.ui.FuncEvent;
import org.mch.biz.ui.FuncPanel;
import org.mch.swingm.core.MButton;
import org.mch.swingm.ext.METextField;

/**
 * 描述：按位 左移 右移 Panel类；<BR/>
 * 
 * @author MCH；Date：2008-06-18；<BR/>
 *
 */
public class AnWeiZuoYouYi_Panel extends FuncPanel {
	private static final long serialVersionUID = -3576459364802038353L;
	private METextField text_weiyishu;
	private METextField text_wys_buma;
	private MButton btn_js_erjinzhi;
	private MButton btn_weiyi_zuo1;
	private JLabel label;
	private JLabel label_1;
	private METextField text_weiyijieguo;
	private MButton btn_zuo_yi;
	private JLabel label_2;
	private JLabel lbljava;
	private JLabel label_3;
	private JLabel label_4;
	private JLabel label_5;
	private JLabel label_6;
	private JScrollPane scrollPane;
	private JTextArea textArea;
	private JButton btn_clear;
	private METextField text_wys_fanma;
	private METextField text_wys_yuanma;
	private MButton btn_you_yi;
	private MButton btn_you_yi_wfh;
	private METextField text_yi_wei;
	private MButton btn_weiyi_you1;
	private MButton btn_weiyi_you1_wfh;

	public AnWeiZuoYouYi_Panel() {

		initGUI();
	}

	private void initGUI() {
		setLayout(null);
		add(getText_weiyishu());
		add(getText_wys_buma());
		add(getBtn_js_erjinzhi());
		add(getBtn_weiyi_zuo1());
		add(getLabel());
		add(getLabel_1());
		add(getText_weiyijieguo());
		add(getBtn_zuo_yi());
		add(getLabel_2());
		add(getLbljava());
		add(getLabel_3());
		add(getLabel_4());
		add(getLabel_5());
		add(getLabel_6());
		add(getScrollPane());
		add(getText_wys_fanma());
		add(getText_wys_yuanma());
		add(getBtn_you_yi());
		add(getBtn_you_yi_wfh());
		add(getText_yi_wei());
		add(getBtn_weiyi_you1());
		add(getBtn_weiyi_you1_wfh());
	}

	public METextField getText_weiyishu() {
		if (text_weiyishu == null) {
			text_weiyishu = new METextField("位移数：");
			text_weiyishu.setBounds(12, 127, 142, 25);
			text_weiyishu.setTextType("int");
		}
		return text_weiyishu;
	}

	public METextField getText_wys_buma() {
		if (text_wys_buma == null) {
			text_wys_buma = new METextField();
			text_wys_buma.getLabel().setText("位移数补码：");
			text_wys_buma.setBounds(12, 164, 379, 25);
		}
		return text_wys_buma;
	}

	public MButton getBtn_js_erjinzhi() {
		if (btn_js_erjinzhi == null) {
			btn_js_erjinzhi = new MButton();
			btn_js_erjinzhi.setText("计算二进制");
			btn_js_erjinzhi.setBounds(403, 164, 98, 25);
			btn_js_erjinzhi.addActionListener(getEvent());
		}
		return btn_js_erjinzhi;
	}

	public MButton getBtn_weiyi_zuo1() {
		if (btn_weiyi_zuo1 == null) {
			btn_weiyi_zuo1 = new MButton();
			btn_weiyi_zuo1.setText("左移一位 << ：");
			btn_weiyi_zuo1.setBounds(12, 255, 152, 25);
			btn_weiyi_zuo1.addActionListener(getEvent());
		}
		return btn_weiyi_zuo1;
	}

	@Override
	protected FuncEvent createEvent() {
		return new AnWeiZuoYouYi_Event(this);
	}

	public JLabel getLabel() {
		if (label == null) {
			label = new JLabel("1、符号位：0为正数，1为负数。");
			label.setForeground(Color.RED);
			label.setBorder(new LineBorder(new Color(192, 192, 192), 2));
			label.setFont(new Font("宋体", Font.PLAIN, 12));
			label.setBounds(12, 12, 245, 25);
		}
		return label;
	}

	public JLabel getLabel_1() {
		if (label_1 == null) {
			label_1 = new JLabel("2、正数的原码、反码、补码为其本身。");
			label_1.setForeground(Color.RED);
			label_1.setBorder(new LineBorder(Color.LIGHT_GRAY, 2));
			label_1.setFont(new Font("宋体", Font.BOLD, 12));
			label_1.setBounds(12, 42, 245, 25);
		}
		return label_1;
	}

	public METextField getText_weiyijieguo() {
		if (text_weiyijieguo == null) {
			text_weiyijieguo = new METextField("位移结果：");
			text_weiyijieguo.setTextType("int");
			text_weiyijieguo.setBounds(259, 127, 204, 25);
		}
		return text_weiyijieguo;
	}

	public MButton getBtn_zuo_yi() {
		if (btn_zuo_yi == null) {
			btn_zuo_yi = new MButton();
			btn_zuo_yi.setToolTipText("左移运算符；num << 1,相当于num乘以2");
			btn_zuo_yi.setText("<<");
			btn_zuo_yi.setBounds(475, 127, 57, 25);
			btn_zuo_yi.addActionListener(getEvent());
		}
		return btn_zuo_yi;
	}

	public JLabel getLabel_2() {
		if (label_2 == null) {
			label_2 = new JLabel("3、负数的反码是在其原码的基础上, 符号位不变，其余各个位取反。");
			label_2.setForeground(Color.RED);
			label_2.setFont(new Font("宋体", Font.PLAIN, 12));
			label_2.setBorder(new LineBorder(new Color(192, 192, 192), 2));
			label_2.setBounds(269, 12, 379, 25);
		}
		return label_2;
	}

	public JLabel getLbljava() {
		if (lbljava == null) {
			lbljava = new JLabel("4、Java中数都是有符号数。");
			lbljava.setForeground(Color.RED);
			lbljava.setFont(new Font("宋体", Font.PLAIN, 12));
			lbljava.setBorder(new LineBorder(Color.LIGHT_GRAY, 2));
			lbljava.setBounds(269, 42, 379, 25);
		}
		return lbljava;
	}

	public JLabel getLabel_3() {
		if (label_3 == null) {
			label_3 = new JLabel("5、负数的反码=它的原码符号位不变, 其他位取反。");
			label_3.setForeground(Color.RED);
			label_3.setFont(new Font("宋体", Font.PLAIN, 12));
			label_3.setBorder(new LineBorder(Color.LIGHT_GRAY, 2));
			label_3.setBounds(12, 72, 379, 25);
		}
		return label_3;
	}

	public JLabel getLabel_4() {
		if (label_4 == null) {
			label_4 = new JLabel("6、负数的补码=它的反码+1。");
			label_4.setForeground(Color.RED);
			label_4.setFont(new Font("宋体", Font.PLAIN, 12));
			label_4.setBorder(new LineBorder(new Color(192, 192, 192), 2));
			label_4.setBounds(403, 72, 245, 25);
		}
		return label_4;
	}

	public JLabel getLabel_5() {
		if (label_5 == null) {
			label_5 = new JLabel("8、0的反码, 补码都是0。");
			label_5.setForeground(Color.RED);
			label_5.setFont(new Font("宋体", Font.PLAIN, 12));
			label_5.setBorder(new LineBorder(new Color(192, 192, 192), 2));
			label_5.setBounds(403, 98, 245, 25);
		}
		return label_5;
	}

	public JLabel getLabel_6() {
		if (label_6 == null) {
			label_6 = new JLabel("7、在计算机运算的时候, 都是以补码的方式来运算的。");
			label_6.setForeground(Color.RED);
			label_6.setFont(new Font("宋体", Font.BOLD, 12));
			label_6.setBorder(new LineBorder(Color.LIGHT_GRAY, 2));
			label_6.setBounds(12, 98, 379, 25);
		}
		return label_6;
	}

	public JScrollPane getScrollPane() {
		if (scrollPane == null) {
			scrollPane = new JScrollPane();
			scrollPane.setBounds(176, 254, 472, 226);
			scrollPane.setViewportView(getTextArea());
			scrollPane.setColumnHeaderView(getBtn_clear());
		}
		return scrollPane;
	}

	public JTextArea getTextArea() {
		if (textArea == null) {
			textArea = new JTextArea();
			textArea.setBorder(new LineBorder(Color.WHITE, 2));
			textArea.setFont(new Font("宋体", Font.PLAIN, 13));
		}
		return textArea;
	}

	public JButton getBtn_clear() {
		if (btn_clear == null) {
			btn_clear = new JButton("清空");
			btn_clear.setFont(new Font("宋体", Font.BOLD, 12));
			btn_clear.addActionListener(getEvent());
		}
		return btn_clear;
	}

	public METextField getText_wys_fanma() {
		if (text_wys_fanma == null) {
			text_wys_fanma = new METextField();
			text_wys_fanma.getLabel().setText("位移数反码：");
			text_wys_fanma.setBounds(12, 191, 379, 25);
		}
		return text_wys_fanma;
	}

	public METextField getText_wys_yuanma() {
		if (text_wys_yuanma == null) {
			text_wys_yuanma = new METextField();
			text_wys_yuanma.getLabel().setText("位移数原码：");
			text_wys_yuanma.setBounds(12, 218, 379, 25);
		}
		return text_wys_yuanma;
	}

	public MButton getBtn_you_yi() {
		if (btn_you_yi == null) {
			btn_you_yi = new MButton();
			btn_you_yi.setToolTipText("右移运算符；num >> 1,相当于num除以2");
			btn_you_yi.setText(">>");
			btn_you_yi.setBounds(533, 127, 57, 25);
			btn_you_yi.addActionListener(getEvent());
		}
		return btn_you_yi;
	}

	public MButton getBtn_you_yi_wfh() {
		if (btn_you_yi_wfh == null) {
			btn_you_yi_wfh = new MButton();
			btn_you_yi_wfh.setToolTipText("无符号右移，忽略符号位，空位都以0补齐");
			btn_you_yi_wfh.setText(">>>");
			btn_you_yi_wfh.setBounds(591, 127, 57, 25);
			btn_you_yi_wfh.addActionListener(getEvent());
		}
		return btn_you_yi_wfh;
	}

	public METextField getText_yi_wei() {
		if (text_yi_wei == null) {
			text_yi_wei = new METextField("移位：");
			text_yi_wei.setTextType("int");
			text_yi_wei.setBounds(160, 127, 97, 25);
			text_yi_wei.setValue(1);
		}
		return text_yi_wei;
	}

	public MButton getBtn_weiyi_you1() {
		if (btn_weiyi_you1 == null) {
			btn_weiyi_you1 = new MButton("右移一位 >> ：");
			btn_weiyi_you1.setBounds(12, 292, 152, 25);
			btn_weiyi_you1.addActionListener(getEvent());
		}
		return btn_weiyi_you1;
	}
	public MButton getBtn_weiyi_you1_wfh() {
		if (btn_weiyi_you1_wfh == null) {
			btn_weiyi_you1_wfh = new MButton("无符号右移一位 >>> ：");
			btn_weiyi_you1_wfh.setMargin(new Insets(2, 0, 2, 0));
			btn_weiyi_you1_wfh.setBounds(12, 329, 152, 25);
			btn_weiyi_you1_wfh.addActionListener(getEvent());
		}
		return btn_weiyi_you1_wfh;
	}
}
